package test2_annonation.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import test2_annonation.BookDao2;
import test2_annonation.BookService2;


@Component
public class BookSerivce2Impl implements BookService2 {

    @Value("${name}")
    private String name;
    @Value("${age}")
    private int age;
    @Value("${sex}")
    private String sex;


    @Autowired
    @Qualifier("BookDao22")
    //这里类型应该写的是接口类型，解耦
    //当写接口类型的时候，面对不同的实现类，只需要在Qualifier注解中写入实现类的id即可
    private BookDao2 bookDao2;

    public void save() {
        System.out.println(name+"--"+age+"--"+sex);
        System.out.println("book serive2 save");
        bookDao2.search();
    }
}
